Hello, I have an odd problem. This bit of DXL gives me an internal error:
void test()
{
return
}
print (int addr_(test)) ""
void test(string blah)
{
return
}
print (int addr_(test)) ""
SSloan - Tue Oct 12 15:36:28 EDT 2010 |
Re: Using addr_() on functions I found no syntax way, to get the address of a function without parameters, without calling it. If you find a way -> greatly appreciated :-) Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Using addr_() on functions Mathias Mamsch - Tue Oct 12 20:01:22 EDT 2010 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS This is only halfways, i haven't got it right for function returning nothing (void):
int getAddr(char pr(void))
{
int a = (int addr_ pr)
return(a)
}
char test()
{
print "hello\n"
return('0')
}
char getChar(char pr(void))
{
return(pr)
}
int i
i = getAddr(test)
print i
char c = getChar(addr_ i)
print c
|
Re: Using addr_() on functions
Problem solved
int* PtrOps_intStarAddressOf(_m &v) {
int *val = &(addr_ (int (addr_ (v))));
return (val);
}
int PtrOps_addressOfVar(_m& anyVar) {
int temp = (int addr_ PtrOps_intStarAddressOf(anyVar));
return temp;
}
int PtrOps_internalIntContentOfAddress(int& refToInt) {
int content = refToInt;
return content;
}
int PtrOps_intContentOfAddress(int address) {
return (PtrOps_internalIntContentOfAddress(addr_ address));
}
int PtrOps_addressOfVoidFunctionWithNoParameterHelper(int dummyParameterOne, void function()) {
int addressOfParameterOne;
int contentOfParameterOne;
int addressOfParameterTwo;
int contentOfParameterTwo;
addressOfParameterOne = PtrOps_addressOfVar(dummyParameterOne);
contentOfParameterOne = PtrOps_intContentOfAddress(addressOfParameterOne);
//--------------------------------------------------------------------------
// DOORS blows up if you get the address of "void function(void)" function
// directly. Alternate approach:
// 1) Pass in a dummy int parameter prior to the function parameter.
// 2) Figure out the dummy address.
// 3) We know the temperamental function parameter content is 4 bytes ahead.
// 4) Look four bytes ahead and extract an int that lies there.
// 5) Done
//--------------------------------------------------------------------------
addressOfParameterTwo = addressOfParameterOne + 4;
contentOfParameterTwo = PtrOps_intContentOfAddress(addressOfParameterTwo);
return contentOfParameterTwo;
}
int PtrOps_addressOfVoidFunctionWithNoParameter(void function()) {
int dummyParameterOne = 1111;
return PtrOps_addressOfVoidFunctionWithNoParameterHelper(dummyParameterOne, function);
}
int PtrOps_addressOfVoidFunctionWithOneNonRefParameter(void function(_m)) {
return (int (addr_ function));
}
void callNoParameterVoidFunction(void function()) {
function();
}
void callOneParameterVoidFunction(void function(_m)) {
function("one");
}
void oneParameter(string msg) {
print ">>> Hello from void function with " msg " parameter! <<<\n";
}
void noParameter() {
print ">>> Hello from void function with no parameter! <<<\n";
}
void addressOfFunctionDemo() {
print("I'm calling a one parameter void function directly\n");
oneParameter("one");
print("I'm calling a no parameter void function directly\n");
noParameter();
print("\n");
print("I'm calling a one parameter void function by passing function by typed-function signature\n");
callOneParameterVoidFunction( oneParameter );
print("I'm calling a no parameter void function by passing function by typed-function signature\n");
callNoParameterVoidFunction( noParameter );
print("\n");
int addressOfVoidFunctionWithOneNonRefParameter = PtrOps_addressOfVoidFunctionWithOneNonRefParameter( oneParameter );
int addressOfVoidFunctionWithNoParameter = PtrOps_addressOfVoidFunctionWithNoParameter( noParameter );
print("The address of a one parameter void function is (in decimal) " (addressOfVoidFunctionWithOneNonRefParameter) "\n");
print("The address of a no parameter void function is (in decimal) " (addressOfVoidFunctionWithNoParameter) "\n");
print("\n");
print("I'm calling a one parameter void function by hacking-in the address\n");
callOneParameterVoidFunction( addr_ addressOfVoidFunctionWithOneNonRefParameter );
print("I'm calling a no parameter void function by hacking-in the address\n");
callNoParameterVoidFunction( addr_ addressOfVoidFunctionWithNoParameter );
}
addressOfFunctionDemo();
|
Re: Using addr_() on functions SystemAdmin - Fri Oct 15 14:50:13 EDT 2010
Problem solved
int* PtrOps_intStarAddressOf(_m &v) {
int *val = &(addr_ (int (addr_ (v))));
return (val);
}
int PtrOps_addressOfVar(_m& anyVar) {
int temp = (int addr_ PtrOps_intStarAddressOf(anyVar));
return temp;
}
int PtrOps_internalIntContentOfAddress(int& refToInt) {
int content = refToInt;
return content;
}
int PtrOps_intContentOfAddress(int address) {
return (PtrOps_internalIntContentOfAddress(addr_ address));
}
int PtrOps_addressOfVoidFunctionWithNoParameterHelper(int dummyParameterOne, void function()) {
int addressOfParameterOne;
int contentOfParameterOne;
int addressOfParameterTwo;
int contentOfParameterTwo;
addressOfParameterOne = PtrOps_addressOfVar(dummyParameterOne);
contentOfParameterOne = PtrOps_intContentOfAddress(addressOfParameterOne);
//--------------------------------------------------------------------------
// DOORS blows up if you get the address of "void function(void)" function
// directly. Alternate approach:
// 1) Pass in a dummy int parameter prior to the function parameter.
// 2) Figure out the dummy address.
// 3) We know the temperamental function parameter content is 4 bytes ahead.
// 4) Look four bytes ahead and extract an int that lies there.
// 5) Done
//--------------------------------------------------------------------------
addressOfParameterTwo = addressOfParameterOne + 4;
contentOfParameterTwo = PtrOps_intContentOfAddress(addressOfParameterTwo);
return contentOfParameterTwo;
}
int PtrOps_addressOfVoidFunctionWithNoParameter(void function()) {
int dummyParameterOne = 1111;
return PtrOps_addressOfVoidFunctionWithNoParameterHelper(dummyParameterOne, function);
}
int PtrOps_addressOfVoidFunctionWithOneNonRefParameter(void function(_m)) {
return (int (addr_ function));
}
void callNoParameterVoidFunction(void function()) {
function();
}
void callOneParameterVoidFunction(void function(_m)) {
function("one");
}
void oneParameter(string msg) {
print ">>> Hello from void function with " msg " parameter! <<<\n";
}
void noParameter() {
print ">>> Hello from void function with no parameter! <<<\n";
}
void addressOfFunctionDemo() {
print("I'm calling a one parameter void function directly\n");
oneParameter("one");
print("I'm calling a no parameter void function directly\n");
noParameter();
print("\n");
print("I'm calling a one parameter void function by passing function by typed-function signature\n");
callOneParameterVoidFunction( oneParameter );
print("I'm calling a no parameter void function by passing function by typed-function signature\n");
callNoParameterVoidFunction( noParameter );
print("\n");
int addressOfVoidFunctionWithOneNonRefParameter = PtrOps_addressOfVoidFunctionWithOneNonRefParameter( oneParameter );
int addressOfVoidFunctionWithNoParameter = PtrOps_addressOfVoidFunctionWithNoParameter( noParameter );
print("The address of a one parameter void function is (in decimal) " (addressOfVoidFunctionWithOneNonRefParameter) "\n");
print("The address of a no parameter void function is (in decimal) " (addressOfVoidFunctionWithNoParameter) "\n");
print("\n");
print("I'm calling a one parameter void function by hacking-in the address\n");
callOneParameterVoidFunction( addr_ addressOfVoidFunctionWithOneNonRefParameter );
print("I'm calling a no parameter void function by hacking-in the address\n");
callNoParameterVoidFunction( addr_ addressOfVoidFunctionWithNoParameter );
}
addressOfFunctionDemo();
|
Re: Using addr_() on functions Mathias Mamsch - Fri Oct 15 15:18:13 EDT 2010 When DXL throws in a banana peel onto the road (like crashing DOORS), we can either talk ourselves out of the need or use some C programming stunts to find an alternate route around the mess. |
Re: Using addr_() on functions SystemAdmin - Fri Oct 15 16:26:35 EDT 2010 Do you think you could manage to do this for THIS problem? Consider it a challenge! |